<%--
  Created by IntelliJ IDEA.
  User: Williams
  Date: 2015/9/5
  Time: 15:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set value="${pageContext.request.contextPath}" var="ctx"></c:set>
<html>
<head>
    <title>Hello World</title>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/css/bootstrap.ext.css">
</head>
<body>
  <h1>hello world</h1>
  <div class="container">
    <div class="row  m_center ">
      <form action="${ctx}/login" method="post" class="form-inline">
        <div class="row  buttom10 top10">
        <div class="form-group col-lg-4 ">
          <label>Username</label>
          <input type="text" class="form-control" name="name" placeholder="name">
        </div>
        </div>
        <div class="row top10 buttom10">
        <div class="form-group col-lg-4">
          <label >Password</label>
          <input type="password" class="form-control" name="password" placeholder="Password">
        </div>
        </div>
        <div class="row ">
          <button type="submit" class="btn btn-default col-lg-1">Submit</button>
        </div>
      </form>
    </div>
    <div class="row top10">
      <table class="table"><thead >
      <th>序号</th>
      <th>内容</th>
      <th>描述</th>
      <th>其他</th>
      </thead>

      </table>
        <table class="table-bordered">
          <thead class="">
            <th>序号</th>
            <th>内容</th>
            <th>描述</th>
            <th>其他</th>
          </thead>
        </table>
    </div>
  </div>

</body>
<script type="text/javascript" src="${ctx}/js/jquery.min.js"></script>
<script type="text/javascript" src="${ctx}/js/bootstrap.js"></script>
<script type="text/javascript">

  var college = {};
  college.showUI = function(e,f) {
    var html = f;
    $(e).append(html);
  }
  college.defaultParse = function(d,m) {
    var html=""
    for (var i=0;i< d.length;i++) {
      html=html + "<tr>" ;
      for (var p in m ) {
        html = html + "<td>"+d[i][m[p]]+"</td>"
      }
      html = html + "</tr>";
    }
    return html;
  }

   /**
   *  遍历对象属性
   *  @param m
   * */
  college.iterateParams = function(m) {
    for(var p in m) {
      if(typeof (m[p]) == "function") {
        m[p]();
      } else {
        alert(m[p]);
      }
    }
  }
//  college.iterateParams({id:12,name:'xsdfsd月',method:function() {alert('hello world')}});
//  alert(college.defaultParse([{id:'123',name:'hksde多多',val:'aklsjdlfa'}],{1:'id',2:'name',3:'val'}));
  college.showUI("thead",college.defaultParse([{id:'123',name:'hksde多多',val:'aklsjdlfa'}],{1:'id',2:'name',3:'val'}));
</script>
</html>
